#!/bin/bash
script_path=$HOME/.ark

echo "downloading scripts"
mkdir -p $script_path
curl -o $script_path/ark https://gitee.com/lastingman/ohos-tools/raw/main/ark
curl -o $script_path/ark.sh https://gitee.com/lastingman/ohos-tools/raw/main/example.sh
curl -o $script_path/options.sh https://gitee.com/lastingman/ohos-tools/raw/main/options.sh


echo "changing ~/.bashrc"
if ! echo "$PATH" | grep -q "$script_path"; then
    echo "export PATH=\$PATH:$script_path" >> ~/.bashrc
fi

if ! grep -Fxq 'eval "$(ark init)"' ~/.bashrc; then
    echo 'eval "$(ark init)"' >> ~/.bashrc
fi

if [ ! -f ~/.tmux.conf ]; then
    echo "creating tmux config"
    cat <<EOT >> ~/.tmux.conf
set -g mouse on
# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1
EOT
else
    echo "tmux config already exists, skip creating tmux config"
fi

echo "restart terminal or run 'source ~/.bashrc' to apply changes."
